package com.woniu.hospital.controller;

import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.woniu.hospital.domain.HosptilpriceType;
import com.woniu.hospital.service.IHosptilpriceTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 住院费用类型表Controller
 * 
 * @author wolf-six
 * @date 2023-02-15
 */
@RestController
@RequestMapping("/hosptilprice_type")
public class HosptilpriceTypeController extends BaseController
{
    @Autowired
    private IHosptilpriceTypeService hosptilpriceTypeService;

    /**
     * 查询住院费用类型表列表
     */
    @RequiresPermissions("hospital:hosptilprice_type:list")
    @GetMapping("/list")
    public TableDataInfo list(HosptilpriceType hosptilpriceType)
    {
        startPage();
        List<HosptilpriceType> list = hosptilpriceTypeService.selectHosptilpriceTypeList(hosptilpriceType);
        return getDataTable(list);
    }

    /**
     * 导出住院费用类型表列表
     */
    @RequiresPermissions("hospital:hosptilprice_type:export")
    @Log(title = "住院费用类型表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HosptilpriceType hosptilpriceType)
    {
        List<HosptilpriceType> list = hosptilpriceTypeService.selectHosptilpriceTypeList(hosptilpriceType);
        ExcelUtil<HosptilpriceType> util = new ExcelUtil<HosptilpriceType>(HosptilpriceType.class);
        util.exportExcel(response, list, "住院费用类型表数据");
    }

    /**
     * 获取住院费用类型表详细信息
     */
    @RequiresPermissions("hospital:hosptilprice_type:query")
    @GetMapping(value = "/{hosptilpriceTypeid}")
    public AjaxResult getInfo(@PathVariable("hosptilpriceTypeid") Long hosptilpriceTypeid)
    {
        return success(hosptilpriceTypeService.selectHosptilpriceTypeByHosptilpriceTypeid(hosptilpriceTypeid));
    }

    /**
     * 新增住院费用类型表
     */
    @RequiresPermissions("hospital:hosptilprice_type:add")
    @Log(title = "住院费用类型表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HosptilpriceType hosptilpriceType)
    {
        return toAjax(hosptilpriceTypeService.insertHosptilpriceType(hosptilpriceType));
    }

    /**
     * 修改住院费用类型表
     */
    @RequiresPermissions("hospital:hosptilprice_type:edit")
    @Log(title = "住院费用类型表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HosptilpriceType hosptilpriceType)
    {
        return toAjax(hosptilpriceTypeService.updateHosptilpriceType(hosptilpriceType));
    }

    /**
     * 删除住院费用类型表
     */
    @RequiresPermissions("hospital:hosptilprice_type:remove")
    @Log(title = "住院费用类型表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{hosptilpriceTypeids}")
    public AjaxResult remove(@PathVariable Long[] hosptilpriceTypeids)
    {
        return toAjax(hosptilpriceTypeService.deleteHosptilpriceTypeByHosptilpriceTypeids(hosptilpriceTypeids));
    }
}
